﻿using System;
using UnityEngine;
using System.Collections;
using System.IO;
using System.Threading.Tasks;
using TlsService;
using UnityEngine.UI;

public class MicrophoneRecorder : MonoBehaviour
{

    public Text c;
    private float sendTime =5f;
    private float totalTime = 0;
    private bool bClose;
    private TlsVoiceService tlsVoice;
    private string content;
    void Start()
    {
        tlsVoice = new TlsVoiceService();
        tlsVoice.continu.tls.updateContent += On;
    }

    private void On(string obj)
    {
        c.text = obj;
        totalTime = 0;
        bClose = false;
    }

    private void Update()
    {
        // if(bClose == false)
        // if ((totalTime += Time.deltaTime) >= sendTime)
        // {
        //     bClose = true;
        //     totalTime = 0;
        //     tlsVoice.Close(TlsVoiceService.EType.Continue);
        // }
        //
        // 按下空格键来开始/停止录音
        if (Input.GetKeyDown(KeyCode.Q))
        {
            tlsVoice.Open(TlsVoiceService.EType.Continue);
        }
        if (Input.GetKeyDown(KeyCode.W))
        {
            tlsVoice.Close(TlsVoiceService.EType.Continue);
        }
    }


}